<template>
    <div class="top">
        <div class="left">
            <div class="logo">
                <h2 @click="goHome">天气预报系统</h2>
            </div>
            <div class="content">
                <h3>{{ store.cityInfo.city }}</h3>
                <span>实时天气：{{ store.weather }} {{ store.temperature }}℃</span>
                <span>{{ store.wind }}风 {{ store.windLever }}级</span>
            </div>
        </div>
        <div class="right">
            <div class="empty-box"></div>
            <div class="icon-setting">
                <i class="fa-solid fa-exclamation icon"></i>
                <i class="fa-solid fa-plus icon" @click="add(store.cityTip)"></i>
            </div>
        </div>
    </div>
</template>

<script setup>
import { useStore } from '../store/store';
import { useRoute } from 'vue-router';

const store = useStore()
const route = useRoute()

const add = (city) => {
    store.addCity(city)
}

const goHome = () => {
    route.push('/')
}


</script>

<style scoped lang="scss">
.top {
    display: flex;
    justify-content: space-around;
    align-items: center;
    height: 60px;
    border-bottom: solid 1px rgb(0, 102, 138);
    box-shadow: 0px 4px 8px rgb(0, 88, 93);

    .left {
        display: flex;
        justify-content: space-around;
        align-items: center;
        gap: 20px;
    }

    .right {
        display: flex;
        justify-content: space-around;
        align-items: center;
        margin-left: 10em;
    }

    .logo {
        line-height: 2rem;

        h2 {
            font-size: 1.5rem;
            line-height: 2rem;
        }
    }

    .content {
        display: flex;
        gap: 20px;
        align-items: center;

        h3 {
            font-size: 1.125rem;
        }

        span {
            font-size: 0.875rem;
            line-height: 1.25rem;
        }
    }

    .empty-box {
        flex: 0 0 30%;
        border: solid 1px;
        opacity: 0;
    }

    .icon-setting {
        display: flex;
        width: 70px;
        justify-content: space-around;
        align-items: center;
    }

    .icon {
        cursor: pointer;
    }
}
</style>
